<?php include '../public/header.php' ?>
<?php include '../public/header_public.php' ?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">交易明细（支出）</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">交易单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="jiaonum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">交易金额</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">交易类型</label>
                        <div class="layui-input-block">
                            <select name="type" id="type">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">款项摘要</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhai" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易对象</label>
                        <div class="layui-input-block">
                            <input type="text" name="faer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="daotype" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">资金账户</label>
                        <div class="layui-input-block">
                            <input type="text" name="accname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">经办人</label>
                        <div class="layui-input-block">
                            <input type="text" name="baner" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var param_enginid = getQueryVariable('enginid') || 0;
    var param_typearr = [3,4,6]


    var currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('交易明细(支出)');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_account_zhi_list),where: {enginid:param_enginid,typearr:param_typearr}, page: true
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {


                var typeArr = res.data.type;
                var type_str = '<option value="">请选择</option>';
                for(var i in typeArr){
                    if(typeArr[i].form == 2){
                        if(typeArr[i].type == 3 || typeArr[i].type == 4 || typeArr[i].type == 6){
                            if(typeArr[i].type == res.data.is_type){
                                type_str += '<option value="'+typeArr[i].type+'" selected>'+typeArr[i].name+'</option>';
                            }else{
                                type_str += '<option value="'+typeArr[i].type+'">'+typeArr[i].name+'</option>';
                            }
                        }
                    }
                }
                $('#type').html(type_str);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'mid_number',title:'关联单据',templet: function(d){
                        if(d.midinfo.mid_page){
                            return '<span class="colorlan" onclick="openPage(\'../'+d.midinfo.mid_page+'/show.php?id='+d.midinfo.mid+'\')">'+d.midinfo.mid_number+'</span>';
                        }
                        return '';
                    }}
                ,{field: 'enginname', title: '项目名称'}
                ,{field: 'jiaonum', title: '交易单号'}
                ,{field: 'type_name', title: '交易类型'}
                ,{field: 'money', title: '交易金额(元)',totalRow: true}
                ,{field: 'budname', title: '款项科目'}
                ,{field: 'zhai', title: '款项摘要'}
                ,{field: 'faer', title: '交易对象'}
                ,{field: 'daotype', title: '交易方式'}
                ,{field: 'dt', title: '交易日期'}
                ,{field: 'accname', title: '资金账户'}
                ,{field: 'baner', title: '经办人'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;

            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('../account_shou/show.php?id='+trData.id);
    }



</script>
</body>
</html>
